package com.frame.easy.modular.activiti.controller;

import com.frame.easy.base.controller.BaseController;
import com.frame.easy.modular.activiti.model.HistoryTaskInstance;
import com.frame.easy.modular.activiti.service.HistoryTaskInstanceService;
import com.frame.easy.result.Tips;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * 历史任务实例
 *
 * @author tengchong
 * @date 2020/5/14
 */
@Controller
@RequestMapping("/auth/activiti/history/task-instance")
public class HistoryTaskInstanceController extends BaseController {

    /**
     * view 路径
     */
    private static final String PREFIX = "modular/activiti/history/task-instance/";

    @Autowired
    private HistoryTaskInstanceService service;

    /**
     * 我发起的 view
     *
     * @return String
     */
    @RequestMapping("my/list")
    public String myList() {
        logger.debug("/auth/activiti/history/task-instance/my/list");
        return PREFIX + "my-list";
    }

    /**
     * 我发起的
     *
     * @param task 查询条件
     * @return 数据
     */
    @RequestMapping("select/my")
    @ResponseBody
    @RequiresPermissions("activiti:historic:select:my")
    public Tips selectMy(@RequestBody(required = false) HistoryTaskInstance task) {
        logger.debug("/auth/activiti/history/task-instance/select/my");
        return Tips.getSuccessTips(service.selectMy(task));
    }

    /**
     * 我办理的 view
     *
     * @return String
     */
    @RequestMapping("participate/list")
    public String participateList() {
        logger.debug("/auth/activiti/history/task-instance/list");
        return PREFIX + "participate-list";
    }

    /**
     * 我办理的
     *
     * @param task 查询条件
     * @return 数据
     */
    @RequestMapping("select/participate")
    @ResponseBody
    @RequiresPermissions("activiti:historic:select:participate")
    public Tips selectParticipate(@RequestBody(required = false) HistoryTaskInstance task) {
        logger.debug("/auth/activiti/history/task-instance/select/participate");
        return Tips.getSuccessTips(service.selectParticipate(task));
    }

    /**
     * 所有任务 view
     *
     * @return String
     */
    @RequestMapping("all/list")
    public String allList() {
        logger.debug("/auth/activiti/history/task-instance/all/list");
        return PREFIX + "all-list";
    }

    /**
     * 所有任务
     *
     * @param task 查询条件
     * @return 数据
     */
    @RequestMapping("select/all")
    @ResponseBody
    @RequiresPermissions("activiti:historic:select:all")
    public Tips selectAll(@RequestBody(required = false) HistoryTaskInstance task) {
        logger.debug("/auth/activiti/history/task-instance/select/all");
        return Tips.getSuccessTips(service.selectAll(task));
    }



}
